from primes import PrimeChecker, erastothenes

pc = PrimeChecker(1000 * 1000)

def evalQuadratic(a, b):
    global pc
    
    nrPrimes = 1
    n = 1
    
    while pc.is_prime(n**2 + n*a + b):
        nrPrimes += 1
        n += 1
        
    return nrPrimes

max = 0
primes = erastothenes(2002)

for b in primes:
    if b > 1000: break
    
    for a in [p -1 -b for p in primes]:
        if a > 1000: break
        
        nrPrimes = evalQuadratic(a, b)
        if nrPrimes > max:
            max = nrPrimes
            print nrPrimes, a, b
